package main

import (
	. "designMode/singleton"
)

func main() {
	// 懒汉模式，非线程安全
	instance1 := GetInstance()
	instance2 := GetInstance()
	if instance1 == instance2 {
		println("instance1 == instance2")
	}

	// 懒汉模式，线程安全
	instance3 := GetSafeInstance()
	instance4 := GetSafeInstance()
	if instance3 == instance4 {
		println("instance3 == instance4")
	}

	// 饿汉模式，线程安全
	instance5 := GetHungrySingleton()
	instance6 := GetHungrySingleton()
	if instance5 == instance6 {
		println("instance5 == instance6")
	}
}
